<%-------------------------------------------------------------------
 * 页面名称：returnApplyList.jsp
 * 功能描述：退款申请交易
 * Action  : returnApply.do
 *
 *-------------------------------------------------------------------
--%>
<%@ page contentType="text/html; charset=utf-8"%>
<%@ taglib uri="/WEB-INF/conf/tld/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/conf/tld/struts-tiles.tld" prefix="tiles"%>
<%@ taglib uri="/WEB-INF/conf/tld/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/conf/tld/struts-bean.tld" prefix="bean"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="ipb" uri="/WEB-INF/conf/tld/ipb.tld"%>
<%@ taglib prefix="ad" uri="agiledata"%>
<%@ page import="cn.agiledata.bank.common.util.Constant"%>
<%@ page import="cn.agiledata.bank.account.service.IAccountConst"%>
<%@ page import="cn.agiledata.bank.account.service.AccountSummary"%>
<%
	String path = request.getContextPath();
	AccountSummary user = (AccountSummary) session
			.getAttribute(Constant.SESSION_ACCOUNT_SUMMARY);
%>
<script language=javascript src="<%=path%>/js/popcalendar.js"></script>
<script language="javascript">
	function returnApply() {
		var arrTradeAmounts = document.getElementsByName("tradeAmount");
		var arrReturnAmounts = document.getElementsByName("returnAmount");

		// 检查退款额不为空且不大于实际金额
		for(var i = 0; i < arrReturnAmounts.length; i++) {
			if(arrReturnAmounts[i].value.trim() == "") {
				alert('请输入退款金额');
				arrReturnAmounts[i].focus();
				return;
			}
			if(isNaN(arrReturnAmounts[i].value)) {
				alert('退款金额只能是数字');
				arrReturnAmounts[i].value = "";
				arrReturnAmounts[i].focus();
				return;
			}
			if(arrReturnAmounts[i].value <= 0) {
				alert('退款金额必须大于0');
				arrReturnAmounts[i].value = "";
				arrReturnAmounts[i].focus();
				return;
			}
			if(arrReturnAmounts[i].value * 1 > arrTradeAmounts[i].value * 1) {
				alert('退款额不能大于交易金额！');
				arrReturnAmounts[i].focus();
				return;
			}
			      
			var patten = /^([1-9]{0,1}[0-9]*)([.]{1}[0-9]{0,2})?$/;
			if(!patten.test(arrReturnAmounts[i].value)){
				alert('退款金额格式不正确！');
				arrReturnAmounts[i].focus();
				return;
			}
		}
		
		if(confirm("确认要进行退款么？")) {
			document.frmReturnApply.action="<%=path%>/page/transaction/returnApply.do";
			document.frmReturnApply.submit();
		}

	}
</script>
<form name="frmReturnApply" action="returnTransQuery.do" method="Post" />
	<div id="main">
		<div class="content_right">
			<div style="width:745px;margin-left:10px;">
				<div class="titleinfo">
					退款申请交易
				</div>
				<div class="edit_pass">
					<table width="100%" class="tablestyle">
						<tr>
							<th>
								<span class="blue14">交易编号</span>
							</th>
							<th>
								<span class="blue14">订单编号</span>
							</th>
							<th>
								<span class="blue14">交易对方</span>
							</th>
							<th>
								<span class="blue14">交易类型</span>
							</th>
							<th>
								<span class="blue14">交易模式</span>
							</th>
							<th>
								<span class="blue14">交易状态</span>
							</th>
							<th>
								<span class="blue14">交易时间</span>
							</th>
							<th>
								<span class="blue14">金额</span>
							</th>
							<th>
								<span class="blue14">退款额</span>
							</th>
						</tr>
						<c:forEach var="trans" items="${result.data}" varStatus="status">
							<c:if test="${status.index % 2 == 0}">
								<tr>
							</c:if>
							<c:if test="${status.index % 2 == 1}">
								<tr>
							</c:if>
							<td>
								<bean:write name="trans" property="transId" />
								<input type="hidden" name="id"
									value="<bean:write name="trans" property="id" />" />
							</td>
							<td>
								<bean:write name="trans" property="orderId" />
							</td>
							<td>
								<!--  交易对方 -->
								<logic:equal name="trans" property="actionType.actionId"
									value="InnerTrans">
									<a
										href="<%=path%>/page/common/getAccount.do?accountId=<bean:write name="trans" property="debit.account.id"/>"><bean:write
											name="trans" property="debit.account.name" />
									</a>
								</logic:equal>
								<logic:equal name="trans" property="actionType.actionId"
									value="B2cNetPay">
									<ad:write typeid="BANK_INFO" name="trans" property="bankSeq" />
								</logic:equal>
							</td>
							<td>
								<bean:write name="trans" property="actionType.actionName" />
							</td>
							<td>
								<ad:write typeid="TRADE_TYPE" name="trans" property="tradeType" />
							</td>
							<td>
								<ad:write typeid="TRANS_STATUS" name="trans"
									property="transStatus" />
							</td>
							<td>
								<bean:write name="trans" format="yyyy-MM-dd HH:mm:ss"
									property="beginDate" />
							</td>

							<td>
								<bean:write name="trans" property="amount" />
								<input type="hidden" name="tradeAmount"
									value="<bean:write name="trans" property="amount" />" />
								元
							</td>
							<td>
								<input type="text" class="inputStyle" name="returnAmount"
									size="8" maxlength="9"
									value="<bean:write name="trans" property="amount" />" />
								元
							</td>
							</tr>
						</c:forEach>
					</table>
					</td>
					</tr>
					</table>
					<div class="button_Frame">
						<input type="button" value="退款" class="button_style"
							onClick="returnApply();" />
						&nbsp;&nbsp;
						<%
									if (!IAccountConst.COMPANY_TYPE_GATEWAY.equals(user
									.getCompanyType())) {
						%>
						<input type="button" value="返 回" class="button_style"
							onclick="location.href='<%=path%>/route.do?modual=manage$returnApply'" />
						<%
						} else {
						%>
						<input type="button" value="返 回" class="button_style"
							onclick="location.href='<%=path%>/route.do?modual=return$returnApply'" />
						<%
						}
						%>
					</div>
				</div>
			</div>
		</div>
	</div>
</form>
